// ChildView.h : interface of the CChildView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_CHILDVIEW_H__50C8628F_112A_40D0_9AB2_53368988C69B__INCLUDED_)
#define AFX_CHILDVIEW_H__50C8628F_112A_40D0_9AB2_53368988C69B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "graphics/OpenGLWnd.h"
#include "graphics/Texture.h"	// Added by ClassView
#include "graphics/GrCamera.h"
#include "graphics/GrVector.h"

#include <vector>

const int UPOINTS = 16;
const int VPOINTS = 16;
/////////////////////////////////////////////////////////////////////////////
// CChildView window

const int NUM_PARTICLES = 1000;

class CChildView : public COpenGLWnd
{
	// Construction
public:
	CChildView();

	// Attributes
public:

	// Operations
public:

	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CChildView)
protected:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	//}}AFX_VIRTUAL

	// Implementation
public:
	void OnGLDraw(CDC *pDC);
	virtual ~CChildView();

	void ParticleSystem(DWORD, DWORD);

	double  m_spinAngle;
	UINT_PTR m_spinTimer;

	CTexture m_ground;
	CTexture m_sky;

	// Generated message map functions
protected:
	afx_msg void OnFileSavebmpfile();
	afx_msg void OnTimer(UINT nIDEvent);
	DECLARE_MESSAGE_MAP()
private:
	CGrCamera       m_camera;
	DWORD m_timeElapsed;

	CGrVector wind;
	int particle_enabled[NUM_PARTICLES];
	double particle_px[NUM_PARTICLES];
	double particle_py[NUM_PARTICLES];
	double particle_pz[NUM_PARTICLES];

public:
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnUpdateViewWireframe(CCmdUI *pCmdUI);

	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnCameraPan();
	afx_msg void OnUpdateCameraPan(CCmdUI *pCmdUI);
	afx_msg void OnCameraPitch();
	afx_msg void OnUpdateCameraPitch(CCmdUI *pCmdUI);
	afx_msg void OnCameraRoll();
	afx_msg void OnUpdateCameraRoll(CCmdUI *pCmdUI);
	afx_msg void OnCameraDollyxy();
	afx_msg void OnUpdateCameraDollyxy(CCmdUI *pCmdUI);
	afx_msg void OnAnimateSpinferriswheel();
	afx_msg void OnUpdateAnimateSpinferriswheel(CCmdUI *pCmdUI);


	void Quad(GLdouble p_x, GLdouble p_y, GLdouble p_z, CTexture tex);
public:
	bool m_controlpoints;

private:
	bool m_texturemap;
	CTexture m_texture;
	bool m_interpolateends;
	GLUnurbsObj * m_nurbs;
	void OnFirstDraw();
	bool m_firstdraw;
	bool m_seethrough;
   void Box(GLdouble p_x, GLdouble p_y, GLdouble p_z);

	CTexture m_boxtexture;


	void ActualDraw(bool p_select);

   // The points array
   GLfloat              m_p[UPOINTS][VPOINTS][3];
   // The texture points array
   GLfloat              m_ptex[UPOINTS][VPOINTS][2];

   // Picking and moving support
	int m_selection;     // The currently selected control point
                        // m_selection = u * VPOINTS + v
   // OpenGL parameters when the blocks are drawn.
	GLdouble m_projmatrix[16];
	GLdouble m_modelmatrix[16];
	GLint m_viewport[4];
	GLdouble m_selectiondepth;

	CGrVector m_currentMarbleLocation;
	
	std::string m_cheatCode; // the cheatcode (please store in lowercase)
	std::vector<char> m_pressedSoFar; // keys pressed so far (clear when invalid key is pressed)
	bool m_bigRigs; // crazy cheats and stuff (among them, wall pass-through capability)

	GLYPHMETRICSFLOAT m_gmf[255];
	GLuint m_arialDL;
	bool m_winning;

};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CHILDVIEW_H__50C8628F_112A_40D0_9AB2_53368988C69B__INCLUDED_)
